
#顺序栈
class SeqStack:
    #初始化
    def __init__(self,MAXSIZE = 100):
        self.top = -1
        self.elements = MAXSIZE*[0]
        self.length = 0
    #入栈
    def push(self):
        data = input("请输入入栈元素")
        if self.top ==  len(self.elements)-1:
            return
        self.top+=1
        self.length+=1
        self.elements[self.top] = data
    #出栈
    def pop(self):
        if self.top == -1:
            return
        self.top-=1
        self.length-=1
    #遍历
    def outline(self):
        print("========栈元素========")
        for i in range(self.length-1,-1,-1):
            print(self.elements[i])
        print("=====================")
            
        
if __name__ == "__main__":
    while 1:
        print("\n1-初始化栈      2-元素入栈")
        print("3-元素出栈      4-退出程序\n")
        command = input("请输入您的操作：")
        if(command=="1"):
           sta = SeqStack()
           print("初始化成功")
        elif(command=="2"):
            sta.push()
            sta.outline()
        elif(command=="3"):
            sta.pop()
            sta.outline()
        elif(command=="4"):
            break